export function WxCheckSession() {
  return new Promise((resolve, reject) => {
    wx.checkSession({
      success(data) {
        return resolve(data)
      },
      fail(error) {
        return reject(error)
      }})
  })
};

export function WxLogin() {
  return new Promise((resolve, reject) => {
    wx.login({
      success(data) {
        return resolve(data)
      },
      fail(error) {
        return reject(error)
      }})
  })
};

export function WxGetUserProfile() {
  return new Promise((resolve, reject) => {
    wx.showModal({
      title: '提示',
      content: '小程序需要获取用户信息',
      confirmText: '确定',
      cancelText: '取消',
      success: confirm => {
        if (confirm.confirm) {
          wx.getUserProfile({
            desc: '正在获取',
            success(data) {
              return resolve(data)
            },
            fail(error) {
              return reject(error)
            }})
        }
      }
    })
  })
};
